function [y] = mi( theta, id )
phi2=phi(theta,id);
load('mainfile1.mat');

alpha=theta(1);
beta=theta(2:6); % <1x5 double>
mu=theta(7:31);  % <1x25 double>
chi=theta(34:58);% <1x25 double>
rho=theta(59:63);
c=theta(64);
n=find(consumer_id==id);
k=dimension(n(1));

main=0;
w=rand(100,25); % w=[w1, w2,..., w10], <25x10 double>
for l=1:1:100 % N=100, compute Monte Carlo esimator
    test = w(l,:)- phi2; % (negative) <-> phi 
    h=length(find(test<=0));
    z=[(phi2(find(test<=0))) (1-phi2(find(test>0)))];
    
    Qi=prod(z);
    sum=0;
    s=find(test<=0);    
    for p=1:1:length(s)
        j=s(p);
        delta=mu(j)+ x(n(1),:)*beta'+alpha*chi(j);
        sum=sum+exp(delta);
    end 
    cost=(c+x(n(1),:)*rho');
    temp=log(1+sum)-h*cost;
    mi=exp(temp);
    main=main+(mi/Qi);%main=main+(exp(mi)/Qi);    
end 
    y=main/100;
end

